Skip to content

New example cases #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

wilfonba
Copy link
Contributor

@wilfonba wilfonba commented Jul 15, 2025

User description

Description

This PR adds example cases for supersonic forward and backward facing step and fixes a minor bug in deallocation of CBC variables in mixed cases.

Type of change

Please delete options that are not relevant.

  • Something else
  • Bug fix

Scope

  • This PR comprises a set of related changes with a common goal

How Has This Been Tested?

I've built the documentation locally to ensure the images appear correctly on the examples page and ran both new cases on GPUs.

examples/2D_backward_facing_step/

test2.mp4

examples/2D_forward_facing_step/

test2.mp4

PR Type

Enhancement, Bug fix


Description

  • Add two new supersonic step flow examples

  • Fix CBC variable deallocation logic in mixed cases

  • Include documentation and test metadata for examples


Changes diagram

flowchart LR
  A["Bug Fix"] --> B["CBC Deallocation Logic"]
  C["New Examples"] --> D["Backward Facing Step"]
  C --> E["Forward Facing Step"]
  D --> F["Case Configuration"]
  E --> G["Case Configuration"]
  F --> H["Documentation"]
  G --> I["Documentation"]
Loading

Changes walkthrough 📝

Relevant files
Bug fix
1 files
m_cbc.fpp
Fix CBC coefficient deallocation logic                                     
+19/-10 
Enhancement
2 files
case.py
Add backward facing step case configuration                           
+88/-0   
case.py
Add forward facing step case configuration                             
+86/-0   
Documentation
2 files
README.md
Add backward facing step documentation                                     
+4/-0     
README.md
Add forward facing step documentation                                       
+7/-0     
Tests
2 files
golden-metadata.txt
Add test metadata for backward step                                           
+183/-0 
golden-metadata.txt
Add test metadata for forward step                                             
+183/-0 
Additional files
2 files
golden.txt +501/-0 
golden.txt +506/-0 

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @Copilot Copilot AI review requested due to automatic review settings July 15, 2025 04:05
    @wilfonba wilfonba requested review from a team and sbryngelson as code owners July 15, 2025 04:05
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Bug

    The boundary condition logic in the deallocation code has complex nested conditions that may not correctly handle all edge cases. The mixed use of 'all()' and individual boundary checks could lead to incorrect deallocation behavior.

    if (all((/bc_x%beg, bc_x%end/) <= -5) .and. all((/bc_x%beg, bc_x%end/) >= -13) .or. &
        bc_x%beg <= -5 .and. bc_x%beg >= -13 .or. &
        bc_x%end <= -5 .and. bc_x%end >= -13) then
        @:DEALLOCATE(fd_coef_x)
        if (weno_order > 1) then
            @:DEALLOCATE(pi_coef_x)
        end if
    end if
    
    ! Deallocating CBC Coefficients in y-direction
    if (n > 0) then
        if (all((/bc_y%beg, bc_y%end/) <= -5) .and. all((/bc_y%beg, bc_y%end/) >= -13) .or. &
            bc_y%beg <= -5 .and. bc_y%beg >= -13 .or. &
            bc_y%end <= -5 .and. bc_y%end >= -13) then
            @:DEALLOCATE(fd_coef_y)
            if (weno_order > 1) then
                @:DEALLOCATE(pi_coef_y)
            end if
        end if
    end if
    
    ! Deallocating CBC Coefficients in z-direction
    if (p > 0) then
        if (all((/bc_z%beg, bc_z%end/) <= -5) .and. all((/bc_z%beg, bc_z%end/) >= -13) .or. &
            bc_z%beg <= -5 .and. bc_z%beg >= -13 .or. &
            bc_z%end <= -5 .and. bc_z%end >= -13) then
            @:DEALLOCATE(fd_coef_z)
            if (weno_order > 1) then
                @:DEALLOCATE(pi_coef_z)
            end if
        end if
    Code Duplication

    The two example case files share very similar structure and parameter calculations. Consider extracting common functionality into a shared utility module to reduce duplication and improve maintainability.

    import json
    import math
    
    h = 0.0093
    Re = 5000
    
    gam_a = 1.4
    p0 = 101325
    rho0 = 1
    c0 = math.sqrt(gam_a * p0 / rho0)
    v0 = 3 * c0
    mu = v0 * h / Re
    
    # Configuring case dictionary
    print(
        json.dumps(
            {
                # Logistics
                "run_time_info": "T",
                "x_domain%beg": 0,
                "x_domain%end": 30 * h,
                "y_domain%beg": 0,
                "y_domain%end": 6 * h,
                "cyl_coord": "F",
                "m": 1999,
                "n": 399,
                "p": 0,
                "cfl_adap_dt": "T",
                "cfl_target": 0.5,
                "n_start": 0,
                "t_save": 100 * h / (100 * v0),
                "t_stop": 100 * h / v0,
                # Simulation Algorithm Parameters
                "num_patches": 1,
                "model_eqns": 2,
                "alt_soundspeed": "F",
                "num_fluids": 1,
                "mpp_lim": "F",
                "mixture_err": "F",
                "time_stepper": 3,
                "weno_order": 5,
                "weno_eps": 1.0e-16,
                "weno_avg": "T",
                "weno_Re_flux": "T",
                "avg_state": 2,
                "mapped_weno": "T",
                "null_weights": "F",
                "mp_weno": "T",
                "riemann_solver": 2,
                "wave_speeds": 1,
                "bc_x%beg": -11,
                "bc_x%end": -3,
                "bc_y%beg": -16,
                "bc_y%end": -3,
                "ib": "T",
                "num_ibs": 1,
                "viscous": "T",
                # Formatted Database Files Structure Parameters
                "format": 1,
                "precision": 2,
                "prim_vars_wrt": "T",
                "parallel_io": "T",
                # Fluid Patch: Background
                "patch_icpp(1)%geometry": 3,
                "patch_icpp(1)%x_centroid": 15 * h,
                "patch_icpp(1)%y_centroid": 3.5 * h,
                "patch_icpp(1)%length_x": 30 * h,
                "patch_icpp(1)%length_y": 7 * h,
                "patch_icpp(1)%vel(1)": v0,
                "patch_icpp(1)%vel(2)": 0.0,
                "patch_icpp(1)%pres": p0,
                "patch_icpp(1)%alpha_rho(1)": rho0,
                "patch_icpp(1)%alpha(1)": 1.0,
                # IB Patch: Step
                "patch_ib(1)%geometry": 3,
                "patch_ib(1)%x_centroid": 4 * h,
                "patch_ib(1)%y_centroid": 0 * h,
                "patch_ib(1)%length_x": 12 * h,
                "patch_ib(1)%length_y": 2 * h,
                "patch_ib(1)%slip": "T",
                # Fluids Physical Parameters
                "fluid_pp(1)%gamma": 1.0 / (gam_a - 1.0),
                "fluid_pp(1)%pi_inf": 0.0,
                "fluid_pp(1)%Re(1)": 1 / mu,
            },
            indent=4,
        )
    )

    Copy link

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    Copy link
    Contributor

    @Copilot Copilot AI left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Pull Request Overview

    This PR adds two new example cases for supersonic forward- and backward-facing steps, fixes a bug in the deallocation logic for mixed CBC boundary conditions, and introduces new golden-metadata files for the corresponding tests.

    • Added case.py and README.md for 2D forward-facing step example
    • Added case.py and README.md for 2D backward-facing step example
    • Fixed deallocation conditions in s_finalize_cbc_module for mixed CBC boundaries
    • Introduced new golden-metadata for the two example tests

    Reviewed Changes

    Copilot reviewed 7 out of 11 changed files in this pull request and generated 2 comments.

    Show a summary per file
    File Description
    tests/67C777D8/golden-metadata.txt Golden metadata for backward-facing step test
    tests/665682FA/golden-metadata.txt Golden metadata for forward-facing step test
    src/simulation/m_cbc.fpp Adjusted CBC deallocation logic to cover mixed boundary cases
    examples/2D_forward_facing_step/case.py New forward-facing step configuration script
    examples/2D_forward_facing_step/README.md Documentation for forward-facing step example
    examples/2D_backward_facing_step/case.py New backward-facing step configuration script
    examples/2D_backward_facing_step/README.md Documentation for backward-facing step example
    Comments suppressed due to low confidence (2)

    examples/2D_backward_facing_step/README.md:1

    • [nitpick] The README is missing a reference or background on the backward‐facing step case. Consider adding a citation or brief description of the physical setup to mirror the forward‐facing example.
    # Backward Facing Step (2D)
    

    src/simulation/m_cbc.fpp:1623

    • The new deallocation logic covers mixed CBC boundaries, but there are no unit tests exercising a case where one boundary is in range and the other is out of range. Adding a focused test for mixed bc_x or bc_y values would help prevent regressions.
            @:DEALLOCATE(vel_in, vel_out, pres_in, pres_out, Del_in, Del_out, alpha_rho_in, alpha_in)
    

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    1 participant